package jsyf.oa.web.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger配置项<br/>
 *
 * @author pengc
 * @see jsyf.oa.web.swagger.SwaggerConfig
 * @since 2017/10/21
 */
@Configuration
@EnableSwagger2
@EnableWebMvc
@ComponentScan(basePackages = {"jsyf.oa.web"})
public class SwaggerConfig extends WebMvcConfigurationSupport {

	@Bean
	public Docket swaggerSpringMvcPlugin() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("business-api")
				.select()
				.paths(PathSelectors.any())
				.apis(RequestHandlerSelectors.basePackage("jsyf.oa.web"))
				.build();
	}

	/**
	 * swagger api 信息描述<br/>
	 * @return {@link ApiInfo swagger API 对象}
	 */
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("OA系统 API")
				.description("了解更多OA信息：http://www.oa.ershouhui.com/")
				.termsOfServiceUrl("http://blog.didispace.com/")
				.license("License Version 1.0")
				.contact("OA开发组")
				.version("1.0")
				.build();
	}
}
